package com.qf.api;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.Map;
import java.util.Set;

/**
 * @Author ztf
 * @Date 19:24 2021/11/24
 **/
@FeignClient(name = "sms-platform-cache")
@RequestMapping(value = "/cache")
public interface CacheFeign {
    @GetMapping(value = "/keys/{key}")
    public Set<String> keys(@PathVariable(value = "key") String key);


    @RequestMapping(value = "/hmget/{key}", method = RequestMethod.GET)
    public Map hMGet(@PathVariable("key") String key);

    @RequestMapping(value = "/incr", method = RequestMethod.GET)
    public Long incr(@RequestParam("key") String key, @RequestParam("delta") long delta);

    // 对hash结构的某一个field进行incr操作
    @PostMapping("/hincr")
    public Long hincr(@RequestParam(value = "key") String key, @RequestParam(value = "field") String field, @RequestParam(value = "delta") Long delta);


    @RequestMapping(value = "/get/{key}", method = RequestMethod.GET)
    public String get(@PathVariable("key") String key);

    // zset结构的根据分数查询数据
    @RequestMapping(value = "/zrangebyscore/{key}",method = RequestMethod.GET)
    public Set<String> zRangeByScore(@PathVariable(value = "key") String key, @RequestParam("min") Long min, @RequestParam(value = "max") Long max);
}

